home *** CD-ROM | disk | FTP | other *** search
- Path: s02.pavilion.co.uk!usenet
- From: AJRobb@pavilion.co.uk (Andy J Robb)
- Newsgroups: comp.lang.java,comp.lang.c,comp.lang.c++
- Subject: Re: Correct mod/rem (was: Problem with % (remainder) operator
- Date: Mon, 22 Jan 1996 22:11:18 GMT
- Organization: Pavilion Internet plc
- Message-ID: <4e120p$p3g@s02.pavilion.co.uk>
- References: <4dc86s$gha@news.xs4all.nl> <4d8hnd$74h@news.xs4all.nl> <443322587wnr@almide.demon.co.uk> <142091149wnr@almide.demon.co.uk> <4dguci$le3@news.ox.ac.uk> <hbaker-2201961022380001@10.0.2.15>
- NNTP-Posting-Host: poolc05.pavilion.co.uk
- X-Newsreader: Forte Free Agent 1.0.82
-
- hbaker@netcom.com (Henry Baker) wrote:
-
- Personally, I agree - rounding towards minus infinity is preferred.
- Generally, the IEEE seem to prefer bank rounding as the default.
- This means that the value zero means:
- -0.5 <= answer <= 0.5
- the value 1 means
- 0.5 < answer < 1.5
- the value 2 means
- 1.5 <= answer <= 2.5
-
- Thus 3/-2 == -3/2 == -(3/2) == -(-3/-2) == -2
- 2/-3 == -2/3 == -(2/3) == -(-2/-3) == -1
-
- ISO/ANSI only guarantee that x/y*y + x%y = x (as you know). The
- remainder should be calculated after bank rounding the quotient.
-
- Regards,
-
- -----BEGIN PGP PUBLIC KEY BLOCK-----
- Version: 2.6.2i
-
- mQCNAy/MpRwAAAEEAOt6uBYqT8yv9EmqNhK8m6v+bYi8QjnGW3Bo6iU1gsMj5pa6
- MHgq99c8deADbE3cbJ6uZS9v5pZE3WCf6HCQjlB5iULA5RZzMdAumd/WUzuL9UT3
- B44D9EqqFIL79FlYb56v4oKFqFp1/J2bIpYUwnUvabGzGjdLrpPl4P16x9sNAAUR
- tCNBbmR5IEogUm9iYiA8QUpSb2JiQHBhdmlsaW9uLmNvLnVrPrQhQW5keSBSb2Ji
- IDxBSlJvYmJAcGF2aWxpb24uY28udWs+
- =/wVD
- -----END PGP PUBLIC KEY BLOCK-----
-
-